package cn.itcast.service

import cn.itcast.domain.MetaTable
import cn.itcast.repository.MetaTableRepository
import cn.itcast.utils.ServerResponse
import javax.transaction.Transactional
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Service

/**
  * create by zhangtian on 2019/1/11
  */
@Service
class MetaTableService @Autowired()(metaTableRepository: MetaTableRepository){
  /**
    * 新增表元信息
    * @param metaTable
    * @return
    */
  @Transactional
  def saveMetaTable(metaTable: MetaTable): ServerResponse[MetaTable] ={
    ServerResponse.createBySuccess(metaTableRepository.save(metaTable))
  }

  /**
    * 查询表所有元信息
    * @return
    */
  def findAllMetaTable() = {
    val result = metaTableRepository.findAll()
    ServerResponse.createBySuccess(result)
  }
}
